import { createStore } from "vuex";
export default createStore({
  state: {
    num:10,
    isLoading:false,
    rightClick:{//记录右击信息
      show:false,
      ID:0,
      position:{x:0,y:0}
    },
    seletBoxData:{
      id:"未选中",
      type:"无",
      name:"未定义",
      style:{height: 0,
      left:0,
      top: 0,
      width: 0,
      zIndex: 0},
      data:[["key"],["value"]],
      },
    data:{}
  },
  mutations: {
    changeLoading(state,value){
      state.isLoading=value;
    },
    addNum(state){
      state.num=state.num+10
    },
    rightClickChange(state,value){
      state.rightClick=Object.assign(state.rightClick,value);
    }, 
    setSeletBoxData(state,value){
      console.log(value);
      state.seletBoxData=value;
    }, 
    setData(state,value){
      state.data=value;
      // console.log(value);
    }
  },
  actions: {
    setData(context,value){
      setInterval(()=>{
        let data={}
        for(let i=1;i<10;i++){
            // @ts-ignore
          data[`4000${i}`]=Math.floor(Math.random()*10+1)+i*10
        }
        context.commit('setData',data)
      },1000)
    },
  },
  modules: {}
});
